<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\model;

use think\Model;

class QuestionsModel extends Model
{

    /**
     * 模型名称
     * @var string
     */
    protected $name = 'questions';


    public function getTeacherNameAttr($value,$data){

        $userModel = new UserModel();
        $info = $userModel->where('id',$data['admin_id'])->find();

        $info1 = $userModel->where('id',$data['user_id'])->find();

        $user_nickname = isset($info1['mobile']) ? $info1['mobile'] : '';
        $prefix = substr($user_nickname, 0, 3); // 前三位
        $suffix = substr($user_nickname, -4); // 后四位

        $user_name = $prefix.'***'.$suffix;
        if ($user_nickname == ''){
            $user_name = '匿名网友';
        }

        $articleModel = new PortalPostModel();


        return [
            'teacher_name' => $info['user_login'],
            'user_name' => $user_name,
        ];

    }


}